-
-
Notifications
You must be signed in to change notification settings - Fork 420
Fix exceptions and dynamic casts across dll boundaries #2828
Conversation
Thanks for your pull request and interest in making D better, @John-Colvin! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2828" |
56f69cf
to
afdd25d
Compare
any idea why it is failing on the win with lld-link? t seems kinda arbitrary |
This could be related/help: dlang/dmd#10525 |
@John-Colvin so the failure on win64 doesn't seem related to the other thing but have you confirmed this works on win32? or is that talk about the throw function and catch tables needing to be merged mean there's still a lot to do? |
Using class A(T) {}
template B(T) {
struct C {}
}
void main() {
assert(A!(B!int.C).classinfo.name != A!(B!string.C).classinfo.name); // assertion failure!
} I think the only way to fix this properly is to put the mangle of a type into |
alas mangleof isn't available for subclasses... that means we need a dmd change to make the information available. and mangles can be absurdly large. idk. |
Or some other unique name, but it must be unique that the problem. Something like You can mitigate the cost of doing this by versioning it out on non-Windows platforms and with a little effort you can work out if you're in a different DLL and only do the string comparison in those cases. |
fullyQualfiedName i think also doesn't work without virtuals but i did just remember we have RTInfo so it doesn't need a dmd change per se; it can be done at CT with rtinfo in object.d. not a bad idea, might work at least as a hack. |
How does RTInfo help? |
On Thu, Feb 13, 2020 at 07:17:23AM -0800, Richard Manthorpe wrote:
How does RTInfo help?
it lets druntime extend typeinfo by passing every user-defined class to
a template for CTFE processing.
It can add a instance for the mangleof string.
|
Ah that's the badger! |
TypeInfo names of classes, structs and interfaces are unique now after #3527. |
{ | ||
if (a is b) | ||
return true; | ||
return (a && b) && a.info.name == b.info.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be sensible to restrict the name check to version (Shared)
, i.e., a shared druntime (.{so,dll}
). I think it's reasonable to expect a process with multiple D binaries to share a single druntime; that's not an option with DMD on Windows, I know (so could be enabled for version (DigitalMars) version (Windows)
in general).
It just wouldn't slow down dynamic casting when sticking with a static druntime.
This has landed in #3543, thx John. |
Thanks for sorting this out, sorry for abandoning it for so long |
By making the checks for whether something is a base class use an implementation like
TypeInfo_Class.opEquals
(Can't actually use==
because that does a dynamic cast, which calls_d_isbaseof2
, which means infinite recursion).Relying on name comparison only seems weak, but ultimately the name is the id, just like names of symbols (on linux then the loader will implement ODR by eliminating duplicates based on names anyway, right?).
Effectively this is a reboot of #92
https://issues.dlang.org/show_bug.cgi?id=7020